package com.showgood.view.mediator {
	import com.adobe.crypto.MD5;
	import com.showgood.config.SangoConst;
	import com.showgood.core.AbstractMediator;
	import com.showgood.core.NotificationDispatcher;
	import com.showgood.core.NotificationEvent;
	import com.showgood.model.LoginProxy;
	import com.showgood.view.LoginDialog;
	/**
	 * ...
	 * @author BianPeng
	 */
	public class LoginDialogMediator extends AbstractMediator {
		
		public function LoginDialogMediator(viewComponent:Object = null) {
			super(viewComponent);
		}
		override protected function setupNotifactionHandler(dispatcher:NotificationDispatcher):void {
			dispatcher.addHandler(SangoConst.SOCKET_READY_TO_LOGIN, onSocketReady);
		}
		private function onSocketReady(notify:NotificationEvent):void {
			var _dlg:LoginDialog = viewComponent as LoginDialog;
			var _uname:String = _dlg._name.text;
			var _upwd:String = MD5.hash(_dlg._password.text);
			var _proxy:LoginProxy = sangoFacade.retrieveProxyByType(LoginProxy) as LoginProxy;
			_proxy.login(_uname, _upwd);
		}
	}
}
